package class202205.demo15.demo13;

public class demo20220513 {

    public static void func(int n){
        if ( n == 1){
            System.out.println(n);
            return;
        }
        func(n-1);
        System.out.println(n);
    }
    public static void main1(String[] args) {
        func(10);
    }


    public static int fun(int n){
        if (n == 1){
            return 1;
        }
        int sum = n * fun(n-1);
        return sum;
    }
    public static void main2(String[] args) {
        System.out.println(fun(5));
    }

    public static void suv(int n){
        if (n < 10) {
            System.out.print(n + " ");
            return;
        }
        suv(n/10);
        System.out.print(n%10 + " ");
    }

    public static void main3(String[] args) {
        suv(12345);
    }

    public static int sun(int n){
        if (n == 1){
            return 1;
        }
        int ret = n+sun(n-1);
        return ret;
    }

    public static void main4(String[] args) {
        System.out.println(sun(10));
    }

    public static int timi(int n){
        if (n<10){
            return n;
        }
        int meat = timi(n/10) + n%10;
        return meat;
    }

    public static void main5(String[] args) {
        System.out.println(timi(243));
    }

    public static void print(int[] array,int n) {
        if (n == 1){
            System.out.println(array[n-1]);
            return;
        }
        System.out.println(array[n-1]);
        print(array,n-1);
    }

    public static void main6(String[] args) {
        int[] array = {1,2,3,4,55};
        print(array,array.length);
    }

    public static int fuc(int n){
        if (n == 1){
            return 0;
        }
        if (n == 2){
            return 1;
        }
        int rmp = fuc(n-2)+fuc(n-1);
        return rmp;
    }

    public static void main7(String[] args) {
        System.out.println(fuc(3));
        System.out.println(fuc(5));
        System.out.println(fuc(44));
    }

    public static int swm(int n){
        if (n == 1){
            return 0;
        }
        if (n == 2){
            return 1;
        }
        int f1 = 0;
        int f2 = 1;
        int f3 = 0;
        for (int i = 3; i <= n; i++) {
            f3 = f1 +f2;
            f1 = f2;
            f2 = f3;
        }
        return f3;
    }

    public static void main8(String[] args) {
        System.out.println(swm(1));
        System.out.println(swm(2));
        System.out.println(swm(3));
        System.out.println(swm(5));
        System.out.println(swm(44));
    }

    public static void fuc1(int[]array){
        array = new int[]{1,2,3};
    }
    public static void fuc2(int[]array){
        array[0]=99;
    }
    public static void main(String[] args) {
        int[] array={5,6,7};
        fuc1(array);
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i]+" ");
        }
        System.out.println();

        fuc2(array);
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i]+" ");
        }
        System.out.println();
    }
}
